import request from '@/utils/request'
import type {
  depAllApi,
  uploadApi,
  patientConsultOrderPreReq,
  patientConsultOrderPreApi,
  patientInfoApi,
  patientConsultOrderReq,
  patientConsultOrderApi,
  patientConsultPayReq,
  patientConsultPayApi,
  patientConsultOrderListReq,
  patientConsultOrderListApi
} from '@/types/consult'

// 找医生--查询所有科室-层级
export const depAll = () => request<depAllApi[]>('/dep/all')

// 上传文件/图片
export const upload = (file: File) => {
  const f = new FormData()
  f.append('file', file)
  return request<uploadApi>('/upload', 'post', f)
}
// 问诊-支付页面-计算就诊信息和抵扣信息
export const patientConsultOrderPre = (data: patientConsultOrderPreReq) =>
  request<patientConsultOrderPreApi>('/patient/consult/order/pre', 'get', data)

// 问诊-查询患者详情
export const patientInfo = (id: string) => request<patientInfoApi>(`/patient/info/${id}`)

// 问诊-保存/修改问诊订单
export const patientConsultOrder = (data: patientConsultOrderReq) =>
  request<patientConsultOrderApi>('/patient/consult/order', 'post', data)

//  订单-支付接口
export const patientConsultPay = (data: patientConsultPayReq) =>
  request<patientConsultPayApi>('/patient/consult/pay', 'post', data)

// 问诊记录-订单列表-找医生、极速问诊、开药问诊
export const patientConsultOrderList = (data: patientConsultOrderListReq) =>
  request<patientConsultOrderListApi>('/patient/consult/order/list', 'get', data)

// 订单-取消订单
export const patientOrderCancel = (id: string) => request(`/patient/order/cancel/${id}`, 'put')
// bignumber插件

// 订单-删除订单
export const patientOrder = (id: string) => request(`/patient/order/${id}`, 'delete')
